/*
    调用mutation里面的方法
 */
import {ADD_TODO, DEL_TODO, CHECK_ALL_TODO, DEL_ALL_TODO, GET_ALL_TODOS} from "./mutaaions-types";
import storageUtils from "../utils/storageUtils";

export default {
  addTodo({commit}, item) {
    commit(ADD_TODO, {item})
  },
  delTodo({commit}, index) {
    commit(DEL_TODO, {index})
  },
  selectAll({commit}, value) {
    commit(CHECK_ALL_TODO, {value})
  },
  delAllTodo({commit}) {
    commit(DEL_ALL_TODO)
  },
  getAllTodos({commit}) {
    setTimeout(() => {
      const todos = storageUtils.readTodos()
      commit(GET_ALL_TODOS, {todos})
    }, 1000)
  }
}
